package com.ferry.registry.service;

import com.ferry.registry.domain.registry.RegistryMetaData;
import com.ferry.registry.domain.registry.RegistryState;
import com.ferry.registry.domain.service.ServiceMetaData;
import com.ferry.registry.listener.NotifyListener;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * Created by daiyong
 */
public interface IRegistryService {

	/**
	 * 链接到注册中心
	 * @param address 注册中心地址
	 */
	void connect(String address);

	/**
	 * 注册服务
	 * @param meta
	 */
	void registry(RegistryMetaData registryMetaData);

	/**
	 * 取消注册服务
	 */
	void cancelRegistry(RegistryMetaData registryMetaData);

	/**
	 * 订阅服务
	 */
	void subscribe(ServiceMetaData serviceMetaData, NotifyListener listener);

	/**
	 * 根据服务信息查询注册服务
	 */
	List<RegistryMetaData> query(ServiceMetaData serviceMetaData);

	/**
	 * 消费者信息
	 */
	Map<ServiceMetaData, Integer> consumers();

	/**
	 * 生产者信息
	 */
	Map<RegistryMetaData, RegistryState> providers();

	/**
	 * 判断是否关闭
	 */
	boolean isShutdown();

	/**
	 * 优雅关闭
	 */
	void shutdownGracefully();

}
